package com.luyu.service.Controller;

import com.luyu.service.IMailService;
import jakarta.mail.MessagingException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/test")
@RestController
public class testController {
    @Autowired
    private IMailService mailService;
    @Value("${spring.mail.username}")
    private String mailFrom;
    @RequestMapping//请求路径
    @ResponseBody
    public void testMail() throws MessagingException {
        mailService.sendHtmlMailThymeLeaf1(mailFrom,
                "张小气111111111111",
                "2429069996@qq.com",
                "success",
                "小气包要遭打111");
        System.out.println("邮件发送成功");
    }

    @RequestMapping("/1")
    @ResponseBody
    public void testMail1() throws MessagingException {
        mailService.sendSimpleMail(mailFrom,
                "路与韩",
                "3342380640@qq.com",
                "OK主题",
                "ok兄弟们");
        System.out.println("邮件发送成功");
    }


    @RequestMapping("/2")
    @ResponseBody
    public void testMyMail1() throws MessagingException {
        mailService.sendMySimpleMail(mailFrom,
                "路与韩",
                "3342380640@qq.com",
                "OK主题",
                "ok兄弟们");
        System.out.println("邮件发送成功");
    }
}
